import axios from '@/utils/request'
// Upload a new comment
export function uploadComment(data) {
  return axios({
    url: '/comments',
    method: 'post',
    data
  })
}

// Get comments by parent ID with pagination in ascending order
export function getCommentsByParentIdASC(parentId, pageNum = 1, pageSize = 10) {
  return axios({
    url: `/comments/asc/${parentId}`,
    method: 'get',
    params: {
      pageNum,
      pageSize,
    }
  })
}

// Get comments by parent ID with pagination in descending order 
export function getCommentsByParentIdDESC(parentId, pageNum = 1, pageSize = 10) {
  return axios({
    url: `/comments/desc/${parentId}`, 
    method: 'get',
    params: {
      pageNum,
      pageSize,
    }
  })
}


// Get comments received by a user with pagination in descending order
export function getReceiveCommentsByUserId(userId, pageNum = 1, pageSize = 10) {
  return axios({
    url: '/comments/receive',
    method: 'get',
    params: {
      userId,
      pageNum,
      pageSize
    }
  })
}

// Mark a comment as read
export function markCommentAsRead(data) {
  return axios({
    url: '/comments/mark-as-read',
    method: 'put',
    data
  })
}
